home *** CD-ROM | disk | FTP | other *** search
- package opera;
-
- import java.net.URL;
- import java.net.URLClassLoader;
- import java.security.AllPermission;
- import java.security.CodeSource;
- import java.security.PermissionCollection;
- import java.util.PropertyPermission;
- import sun.applet.AppletThreadGroup;
- import sun.awt.AppContext;
-
- public class PluginClassLoader extends URLClassLoader {
- private static RuntimePermission usePolicyPermission = new RuntimePermission("usePolicy");
- private static PropertyPermission browserReadPerm = new PropertyPermission("browser", "read");
- private static PropertyPermission browserVerReadPerm = new PropertyPermission("browser.version", "read");
- private URL codeBase;
- private AppContext appContext = null;
- private ThreadGroup threadGroup = null;
- private int usageCount = 0;
-
- public PluginClassLoader(URL var1) {
- super(new URL[0], ClassLoader.getSystemClassLoader(), new StreamHandlerFactory());
- this.codeBase = var1;
- }
-
- public void addJar(URL var1) {
- ((URLClassLoader)this).addURL(var1);
- }
-
- ThreadGroup getThreadGroup() {
- try {
- if (this.threadGroup == null || this.threadGroup.isDestroyed()) {
- this.threadGroup = new AppletThreadGroup(this.codeBase + "-threadGroup");
- AppContextCreator var1 = new AppContextCreator(this.threadGroup);
- Object var2 = var1.syncObject;
- synchronized(var2) {
- ((Thread)var1).start();
-
- try {
- var1.syncObject.wait();
- } catch (InterruptedException var5) {
- }
-
- this.appContext = var1.appContext;
- }
-
- Object var8 = null;
- }
- } catch (Exception var7) {
- ((Throwable)var7).printStackTrace(System.err);
- }
-
- return this.threadGroup;
- }
-
- protected void grab() {
- ++this.usageCount;
- this.getThreadGroup();
- }
-
- protected void release() {
- if (this.usageCount > 1) {
- --this.usageCount;
- } else {
- if (this.appContext != null) {
- try {
- this.appContext.dispose();
- } catch (IllegalThreadStateException var9) {
- }
- }
-
- if (this.appContext != null) {
- AppContextCreator var1 = new AppContextCreator(this.threadGroup);
- Object var2 = var1.syncObject;
- synchronized(var2) {
- var1.appContext = this.appContext;
- ((Thread)var1).start();
-
- try {
- var1.syncObject.wait();
- } catch (InterruptedException var7) {
- }
- }
-
- Object var10 = null;
- }
-
- if (this.threadGroup != null) {
- int var11 = this.threadGroup.activeCount();
- Thread[] var12 = new Thread[var11];
- int var3 = this.threadGroup.enumerate(var12);
-
- for(int var4 = 0; var4 < var3; ++var4) {
- try {
- var12[var4].interrupt();
- } catch (Throwable var6) {
- var6.printStackTrace(System.err);
- }
- }
- }
-
- this.usageCount = 0;
- this.appContext = null;
- this.threadGroup = null;
- }
-
- }
-
- public AppContext getAppContext() {
- return this.appContext;
- }
-
- public PermissionCollection getPermissions(CodeSource var1) {
- PermissionCollection var2 = super.getPermissions(var1);
- var2.add(browserReadPerm);
- var2.add(browserVerReadPerm);
- if (var1.getCertificates() != null && !var2.implies(usePolicyPermission) && this.allPermissionsGranted(var1)) {
- var2.add(new AllPermission());
- }
-
- return var2;
- }
-
- boolean allPermissionsGranted(CodeSource var1) {
- return CertificateHandler.checkCertificates(var1);
- }
- }
-